"""
简单测试脚本，验证loadModel方法的功能
"""

from video_annotation_middleware import VideoAnnotationMiddleware

def test_load_model():
    """测试YOLO模型加载功能"""
    print("=" * 50)
    print("测试YOLO模型加载功能")
    print("=" * 50)
    
    try:
        # 创建VideoAnnotationMiddleware实例
        middleware = VideoAnnotationMiddleware()
        
        # 测试loadModel方法
        print("\n1. 测试加载默认模型 (yolo11n.pt)...")
        middleware.loadModel()
        
        # 验证模型已加载
        if middleware._model is not None:
            print("✓ 模型加载成功！")
            print(f"✓ 模型类型: {type(middleware._model)}")
        else:
            print("✗ 模型加载失败：_model为None")
            return False
        
        print("\n" + "=" * 50)
        print("所有测试通过！")
        print("=" * 50)
        return True
        
    except Exception as e:
        print(f"\n✗ 测试失败: {str(e)}")
        import traceback
        traceback.print_exc()
        return False

if __name__ == "__main__":
    success = test_load_model()
    exit(0 if success else 1)
